from queue import  Queue
import threading
import time

# q = Queue(4)
# # q.put(1) #往队列中存数据
# for x in range(4):
#     q.put(x)
# print(q.qsize()) #判断队列
# # 的大小
# print(q.full())
# print(q.empty())
# for x in range(4):
#     print(q.get())

def set_value(q):
    index = 0
    while True:
        q.put(index) #如果你这里满了 我就处于阻塞状态 默认 block 为True
        index+=1
        time.sleep(3)
def get_value(q):
    while True:
        print(q.get()) #如果这里为空 也会处于阻塞状态  默认值为true
        time.sleep(5)

def main():
    q = Queue(4)
    t1 = threading.Thread(target=set_value,args=[q])
    t2 = threading.Thread(target=get_value,args=[q])

    t1.start()
    t2.start()

if __name__ == '__main__':
    main()